import { ApiProperty } from '@nestjs/swagger';
import { BaseEntity, PaginatedResult } from 'src/common/entities/entities';
import { Entity, Column, JoinColumn, ManyToOne } from 'typeorm';
import { AdminUser } from '../../admin-user/entities/admin-user.entity';
export enum OperationRecordType {
    /** 管理员用户 */
    adminUser = 'admin-user',
    /** 剧情 */
    movies = 'movies',
    /** 剧集 */
    moviesEpisode = 'movies-episode',
    /** 图片上传 */
    upload = 'upload',
    /** 分类 */
    category = 'category',
    /** 标签 */
    tags = 'tags',
    /** 系统设置 */
    seting = 'seting',
    /** 菜单 */
    menu = 'menu',
    /** 菜单按钮 */
    menuButton = 'menu-button',
    /** 角色 */
    role = 'role',
}
export enum MethodType {
    GET = 'GET',
    POST = 'POST',
    PUT = 'PUT',
    DELETE = 'DELETE',
    PATCH = 'PATCH'
}
export enum OperateType {
    add = 'add',
    edit = 'edit',
    delete = 'delete',
    login = 'login',
    register = 'register',
    logout = 'logout',
    other = 'other',
}
@Entity({ name: 'operation_record' })
export class OperationRecord extends BaseEntity {
    /** 操作用户ID */
    @ApiProperty({ example: 'userId', description: '操作用户' })
    @Column({ type: 'int', comment: '操作用户' })
    userId: number;
    @ManyToOne(() => AdminUser, (adminUser) => adminUser.operationRecords) // 指定另一面作为第二个参数
    @JoinColumn({ name: 'userId' })
    user: AdminUser;
    /** 操作数据ID */
    @Column({ type: 'int', comment: '操作数据ID' })
    dataId: number;
    /** 操作名称 */
    @Column({ type: 'varchar', comment: '操作名称', length: 255 })
    name: string;
    /** 接口路径 */
    @Column({ type: 'varchar', comment: '接口路径', length: 255 })
    interfacePath: string;
    /** 请求方式 */
    @Column({
        type: 'enum',
        enum: MethodType,
        comment: '请求方式',
    })
    method: MethodType;

    /** 操作内容 */
    @Column({ type: 'text', comment: '操作内容' })
    operation: Array<any> | string;

    /** ip */
    @Column({ type: 'varchar', comment: 'ip' })
    ip: string;

    /** 操作类型 */
    @Column({
        type: 'enum',
        enum: OperateType,
        comment: '操作类型',
    })
    operateType: OperateType;
    /** 操作表 */
    @Column({
        type: 'enum',
        enum: OperationRecordType,
        comment: '操作表',
    })
    outside: OperationRecordType;
}
export class OperationRecordResult extends PaginatedResult {
    @ApiProperty({ example: 'data', description: 'data' })
    data: OperationRecord;
}